import { createRouter, createWebHistory } from "vue-router";

const routerHistory = createWebHistory();

const router = createRouter({
  history: routerHistory,
  routes: [
    {
      path: "",
      redirect: "/login",
      hidden: true,
    },
    {
      path: "/forget",
      hidden: true,
      name: "Forget",
      meta: {
        title: "忘记",
      },
      component: () => import("../views/account/forget.vue"),
    },
    {
      path: "/register",
      hidden: true,
      name: "Register",
      meta: {
        title: "注册",
      },
      component: () => import("../views/account/register.vue"),
    },
    {
      path: "/login",
      hidden: true,
      name: "Login",
      meta: {
        title: "登录",
      },
      component: () => import("../views/account/login.vue"),
    },
    {
      path: "/home",
      name: "Home",
      meta: {
        title: "首页",
        icon: "StarOutlined",
      },
      redirect: "/homeIndex",
      component: () => import("../views/layout/index.vue"),
      children: [
        {
          path: "/homeIndex",
          name: "HomeIndex",
          meta: {
            title: "首页",
          },
          component: () => import("../views/admin/index.vue"),
        },
      ],
    },
    {
      path: "/adminIndex",
      name: "AdminIndex",
      meta: {
        title: "管理總台",
        icon: "DashboardOutlined",
      },
      component: () => import("../views/layout/index.vue"),
      children: [
        {
          path: "/role",
          name: "Role",
          hidden: false,
          meta: {
            title: "角色管理",
          },
          component: () => import("../views/admin/role.vue"),
        },
        {
          path: "/user",
          name: "User",
          hidden: false,
          meta: {
            title: "用户列表",
          },
          component: () => import("../views/admin/user.vue"),
        },
        {
          path: "/menu",
          name: "Menu",
          meta: {
            title: "菜单管理",
          },
          component: () => import("../views/admin/menu.vue"),
        },
      ],
    },
    {
      path: "/news",
      name: "News",
      meta: {
        title: "信息管理",
        icon: "SettingOutlined",
      },
      component: () => import("../views/layout/index.vue"),
      children: [
        {
          path: "/infoList",
          name: "InfoList",
          meta: {
            title: "信息列表",
          },
          component: () => import("../views/info/list.vue"),
        },
        {
          path: "/infoType",
          name: "InfoType",
          meta: {
            title: "信息類別",
          },
          component: () => import("../views/info/type.vue"),
        },
      ],
    },
    {
      path: "/product",
      name: "Product",
      meta: {
        title: "产品管理",
        icon: "ReadOutlined",
      },
      component: () => import("../views/layout/index.vue"),
      children: [
        {
          path: "/productList",
          name: "productList",
          meta: {
            title: "产品列表",
          },
          component: () => import("../views/product/productList.vue"),
        },
        {
          path: "/productType",
          name: "productType",
          meta: {
            title: "产品類別",
          },
          component: () => import("../views/product/productType.vue"),
        },
      ],
    },
    {
      path: "/member",
      name: "Member",
      meta: {
        title: "会员管理",
        icon: "CrownOutlined",
      },
      component: () => import("../views/layout/index.vue"),
      children: [
        {
          path: "/member",
          name: "Member",
          meta: {
            title: "会员管理",
          },
          component: () => import("../views/member/member.vue"),
        },
      ],
    },
  ],
});
export default router;
